// 组件使用的SkuFormData的类型
// {
//   "price": undefined;
//   "weight": undefined;
//   "skuName": "",
//   "skuDesc": "",
//   "skuAttrValueList": [],
//   "skuSaleAttrValueList": [],
//   "skuImageList": [],
//   "skuDefaultImg": "",
// }

export interface SkuItem {
  skuName: string;
  price: undefined | number;
  weight: undefined | number;
  skuDesc: string;
  skuDefaultImg: string;
  skuImageList: SkuImageList;
  // 由于skuAttrValueList和skuSaleAttrValueList发送请求时与组件使用类型不一样，需要分别定义
}

export type SkuImageList = SkuImageItem[];

export interface SkuImageItem {
  id?: number;
  imgName: string;
  imgUrl: string;
  isDefault: "1" | "0";
}

export type SkuAttrValueList = SkuAttrValueItem[];

export interface SkuAttrValueItem {
  attrId: number;
  attrName: string;
  id?: number;
  skuId?: number;
  valueId: number;
  valueName: string;
}

export type SkuSaleAttrValueList = SkuSaleAttrValueItem[];

export interface SkuSaleAttrValueItem {
  id?: number;
  saleAttrId: number;
  saleAttrName: string;
  saleAttrValueId: number;
  saleAttrValueName: string;
  skuId?: number;
  spuId?: number;
}

// 添加或者修改的参数类型
export interface AddOrUpdateSkuParams extends SkuItem {
  category3Id: number;
  id?: number;
  spuId: number;
  skuAttrValueList: SkuAttrValueList;
  skuSaleAttrValueList: SkuSaleAttrValueList;
}

// 组件使用的SkuFormData的类型
export interface SkuFormData extends SkuItem {
  skuAttrValueList: (string | undefined)[];
  skuSaleAttrValueList: Array<string | undefined>;
}

// (string | undefined)[] 和 Array<string | undefined> 等同
// 同一内容的两种形式
// 数组泛型
// Array<number>

export type SkuList = AddOrUpdateSkuParams[];

export interface GetSkuListResponse {
  records: SkuList;
  total: number;
  size: number;
  current: number;
  searchCount: boolean;
  pages: number;
}
